package org.shoukaiseki.common.random;

import org.apache.commons.lang3.RandomUtils;

/**
 * org.shoukaiseki.common.random.RandomChar
 * <br>
 *
 * @author shoukaiseki ブログ http://www.shoukaiseki.top/<br> E-メール jiang28555@Gmail.com<br>
 * @date 2020-11-30 17:01:21<br>
 */
public class RandomChar {

    /**
     * 随机英文大写字母
     * @return
     */
    public static char randomUpperCaseEnglish() {
        return (char)RandomUtils.nextInt(65,91);
    }

    /**
     * 随机英文小写字母
     * @return
     */
    public static char randomLowerCaseEnglish(){
        return (char)RandomUtils.nextInt(97,123);
    }


    /**
     * 随机数字0-9
     * @return
     */
    public static char randomInteger(){
        return (char)RandomUtils.nextInt(48,58);
    }

    /**
     * 随机符号<br>
     * 33-47:符号 48-57:数字(10) 58-64:符号(7) 65-90:大写字母(26) 91-96:符号(6) 97-122:小写字母(26) 123-126:符号(4)
     * <br>
     * >47 +10
     * <br>
     * >54 +36
     * <br>
     * @return
     */
    public static char randomSymbol(){
        int i = RandomUtils.nextInt(33, 65);
        if(i>60){
            return (char)(i+62);
        }
        if(i>54){
            return (char)(i+36);
        }
        if(i>47){
            return (char)(i+10);
        }
        return (char)i;
    }

}
